#include "../../lvgl/lvgl.h"
#include "ui.h"

lv_obj_t * ui_page3 = NULL;
lv_obj_t * Home_modify = NULL;
lv_obj_t * Sleep_modify = NULL;
lv_obj_t * Windy_modify = NULL;

static void event_Demo(lv_event_t *e)
{
    Home_modify_flag = 0;
    Sleep_modify_flag = 0;
    Windy_modify_flag = 0;
    lv_scr_load(ui_page2);
}

void Page_3()
{
    ui_page3 = lv_obj_create(NULL);

    //创建退出修改初值的按钮，设定好标签文本以及回调函数
    lv_obj_t * Demo = lv_btn_create(ui_page3);
    lv_obj_set_width(Demo, lv_pct(20));
    lv_obj_set_height(Demo, lv_pct(10));
    lv_obj_set_x(Demo, lv_pct(5));
    lv_obj_set_y(Demo, lv_pct(5));
    lv_obj_set_align(Demo, LV_ALIGN_TOP_LEFT);
    lv_obj_t * Demo_label = lv_label_create(Demo);
    lv_obj_set_width(Demo_label, lv_pct(100));
    lv_obj_set_height(Demo_label, lv_pct(100));
    lv_obj_set_align(Demo_label , LV_ALIGN_CENTER);
    lv_obj_add_style(Demo_label, &style_32, 0); //给标签添加字体风格
    lv_label_set_text(Demo_label, "退出修改");
    lv_obj_add_event_cb(Demo, event_Demo, LV_EVENT_CLICKED, NULL);

    //创建该页标签
    lv_obj_t *title = lv_label_create(ui_page3);
    lv_obj_set_width(title, lv_pct(50));
    lv_obj_set_height(title, lv_pct(15));
    lv_obj_set_x(title, lv_pct(5));
    lv_obj_set_y(title, lv_pct(20));
    lv_obj_set_align(title, LV_ALIGN_TOP_MID);
    lv_obj_add_style(title, &style_50, 0); //给标签添加字体风格
    lv_label_set_text(title, "选择要修改的模式");

    //创建修改回家模式的按钮，设定好标签，回调函数未写
    Home_modify = lv_btn_create(ui_page3);
    lv_obj_set_width(Home_modify, lv_pct(30));
    lv_obj_set_height(Home_modify, lv_pct(15));
    lv_obj_set_x(Home_modify, lv_pct(2));
    lv_obj_set_y(Home_modify, lv_pct(5));
    lv_obj_set_align(Home_modify, LV_ALIGN_LEFT_MID);
    lv_obj_t * Home_label = lv_label_create(Home_modify);
    lv_obj_set_width(Home_label, lv_pct(100));
    lv_obj_set_height(Home_label, lv_pct(100));
    lv_obj_set_align(Home_label , LV_ALIGN_CENTER);
    lv_obj_add_style(Home_label, &style_50, 0); //给标签添加字体风格
    lv_label_set_text(Home_label, "回家模式");
    lv_obj_add_event_cb(Home_modify, event_mode_modify, LV_EVENT_CLICKED, NULL);

    //创建修改睡眠模式的按钮，设定好标签，回调函数未写
    Sleep_modify = lv_btn_create(ui_page3);
    lv_obj_set_width(Sleep_modify, lv_pct(30));
    lv_obj_set_height(Sleep_modify, lv_pct(15));
    lv_obj_set_x(Sleep_modify, lv_pct(35));
    lv_obj_set_y(Sleep_modify, lv_pct(5));
    lv_obj_set_align(Sleep_modify, LV_ALIGN_LEFT_MID);
    lv_obj_t * Sleep_label = lv_label_create(Sleep_modify);
    lv_obj_set_width(Sleep_label, lv_pct(100));
    lv_obj_set_height(Sleep_label, lv_pct(100));
    lv_obj_set_align(Sleep_label , LV_ALIGN_CENTER);
    lv_obj_add_style(Sleep_label, &style_50, 0); //给标签添加字体风格
    lv_label_set_text(Sleep_label, "睡眠模式");
    lv_obj_add_event_cb(Sleep_modify, event_mode_modify, LV_EVENT_CLICKED, NULL);

    //创建修改回家模式的按钮，设定好标签，回调函数未写
    Windy_modify = lv_btn_create(ui_page3);
    lv_obj_set_width(Windy_modify, lv_pct(30));
    lv_obj_set_height(Windy_modify, lv_pct(15));
    lv_obj_set_x(Windy_modify, lv_pct(68));
    lv_obj_set_y(Windy_modify, lv_pct(5));
    lv_obj_set_align(Windy_modify, LV_ALIGN_LEFT_MID);
    lv_obj_t * Windy_label = lv_label_create(Windy_modify);
    lv_obj_set_width(Windy_label, lv_pct(100));
    lv_obj_set_height(Windy_label, lv_pct(100));
    lv_obj_set_align(Windy_label , LV_ALIGN_CENTER);
    lv_obj_add_style(Windy_label, &style_50, 0); //给标签添加字体风格
    lv_label_set_text(Windy_label, "通风模式");
    lv_obj_add_event_cb(Windy_modify, event_mode_modify, LV_EVENT_CLICKED, NULL);
}